<template>
  <div class="defectOrder flowCloumn h100">
    <div class="constentmain h100">
      <div class="tableContent">
        <listTableNew v-bind="tableSetting" ref="klTable"></listTableNew>
      </div>
    </div>
  </div>
</template>
<script>
import {
  getListApi, //列表
} from "@/api/orderManagement/defectOrder";
export default {
  props: {
    queryData: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      tableSetting: {
        showCustomBtn: false,
        showFilterBtn: false,
        searchObj: {
          searchMethod: (params, sortStr) => {
            this.getTableData(params, sortStr);
          },
          queryData: {
            page: 1,
            pageSize: 15,
            type: null,
          },
          searchArr: [
            {
              type: "input",
              label: "标题",
              model: "title",
            },
            {
              type: "input",
              label: "缺陷关键字",
              model: "realKeys",
              disabled: true,
            },
            {
              label: "状态",
              model: "statusList",
              type: "select",
              multiple: true,
              option: this.$store.getters["dirtData"]("order_defect_status"),
            },
            {
              type: "input",
              label: "工单编号",
              model: "code",
            },
          ],
        },
        actionList: [],
        column: [
          {
            label: "状态",
            prop: "status",
            scopeType: "formate",
            method: (row) => {
              return this.$store.getters["fineDirtDataName"](
                "order_defect_status",
                row.status
              );
            },
            sortable: "custom",
            width: "120px",
          },
          {
            label: "编号",
            prop: "code",
            width: "200px",
            sortable: "custom",
          },
          {
            label: "标题",
            prop: "title",
            showTooltip: true,
            sortable: "custom",
            // formatter: row => {
            //   let title =
            //     row.title ||
            //     this.$store.getters.userInfo.orgName +
            //       "-" +
            //       row.equipmentName +
            //       "-" +
            //       row.keys;
            //   return title;
            // }
          },
          {
            label: "设备管理单位",
            id: "deptManage",
            prop: "deptManageName",
            sortable: "custom",
          },
          {
            label: "设备",
            prop: "equipmentName",
            sortable: "custom",
            showTooltip: true,
          },
          {
            label: "缺陷关键字",
            prop: "keys",
            sortable: "custom",
          },
          {
            label: "专业",
            prop: "major",
            sortable: "custom",
            formatter: (row) => {
              return this.$store.getters["fineDirtDataName"](
                "common_major",
                row.major
              );
            },
            width: "80px",
          },
          {
            label: "缺陷等级",
            prop: "level",
            sortable: "custom",
            formatter: (row) => {
              return this.$store.getters["fineDirtDataName"](
                "defect_order_level",
                row.level
              );
            },
            width: "110px",
          },
          {
            label: "应完成处理时间",
            prop: "expectEndTime",
            sortable: "custom",
            width: "160px",
          },
        ],
        //表格方法
        tableMethods: {
          //点击行的方法
          rowClick: (val) => {
            this.gotoDetails(val);
          },
        },
      },
      searchData: {},
    };
  },

  computed: {},
  created() {
    this.tableSetting.searchObj.queryData = Object.assign(
      this.tableSetting.searchObj.queryData,
      this.queryData
    );
  },
  mounted() {
    this.updateData();
  },
  methods: {
    updateData() {
      this.$refs.klTable.searchData();
    },
    getTableData(params, sortStr) {
      let form = { ...params };
      if (sortStr) {
        form.orders = sortStr;
      }
      getListApi(form)
        .then((res) => {
          let data = res.data.list || [];
          let total = res.data.total || 0;
          this.$set(this.tableSetting, "tableData", data);
          this.$set(this.tableSetting, "totalNumber", total);
        })
        .catch((e) => {
          this.$set(this.tableSetting, "tableData", []);
          this.$set(this.tableSetting, "totalNumber", 0);
        });
    },
    //打开详情页
    gotoDetails(data) {
      let form = {};
      form.id = data.id;
      form.status = data.status;
      let { href } = this.$router.resolve({
        path: "/orderManagement/defectOrder/details",
        query: form,
      });
      window.open(href, "_blank");
    },
  },
};
</script>
<style lang="less" scoped>
.constentmain {
  position: relative;
}
.tableContent {
  min-height: 500px;
  height: 100%;
}
.annotations {
  text-align: left;
  height: 20px;
  line-height: 20px;
  position: absolute;
  bottom: 5px;
}
.circle {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 10px;
}
.invalidReason {
  /deep/.el-dialog {
    width: 400px;
  }
  //
}
</style>
